<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
	<title>Document</title>
	<style type="text/css">
		.dog{
			margin-left: 10px;
			float: left;
		}
	
	</style>
	<script type="text/javascript">
		i=0;
		num = 0;
		function ff(){
			
			var dog=document.getElementById('dog');
			var pic=document.getElementById('pic');
			 dogtime=setInterval(fundog,500)
			function fundog(){
				var left= parseInt(window.getComputedStyle ? window.getComputedStyle(dog,null).marginLeft : dog.currentStyle.marginLeft);
				if(left>=1210){
					num=1;
					}
				else if(left<=10){
					num=0;
				}
				if(num==1){
					pic.src="images/14.gif"
					dog.style.marginLeft=left-150+"px";
				}
				else{
					pic.src="images/13.gif"
					dog.style.marginLeft=left+150+"px";
				}
				
			}
		
		}
			function start(){
				if(i==0){
					ff()
					i=1;
				}
			}
			function stop(){
				i=0;
				clearInterval(dogtime)
			}

	</script>
</head>
<body>
	<input id="start" type="button" value="开始" onclick="start()">
	<input id="stop" type="button" value="停止" onclick="stop()">
	<br>
	<br>
	<div class="dog" id="dog"><img id="pic" src="images/13.gif" alt=""></div>
</body>
</html>